<?php

declare (strict_types=1);
namespace App\Model;

use Hyperf\DbConnection\Model\Model;
/**
 * @property int $id 
 * @property string $sign 
 * @property string $oaid 
 * @property string $imei 
 * @property int $pay_amount 
 * @property string $pkg 
 * @property string $res 
 * @property string $type 
 * @property \Carbon\Carbon $created_at 
 * @property \Carbon\Carbon $updated_at 
 * @property int $user_id 
 * @property int $is_register 
 * @property string $package_name 
 */
class OcpcBaiduSearchLog extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'ocpc_baidu_search_log';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = [];
    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = ['id' => 'integer', 'pay_amount' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'user_id' => 'integer', 'is_register' => 'integer'];

    static function addLog($params = [])
    {
//        log_info(__CLASS__.':'.$params);
        $m = new self();
        $m->oaid = $params['oaid'] ?? '';
        $m->imei = $params['imei'] ?? '';
//        $m->pay_amount = $params['payAmount'] ?? 0;
        $m->user_id = $params['user_id'] ?? 0;
//        $m->sign = $params['sign'];
        $m->res = $params['res'];
        $m->pkg = $params['pkg'];
        $m->type = $params['type'];
        $m->is_register = $params['is_register'] ?? 0;
        return $m->saveOrFail() ? 1 : 0;
    }
}